<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>

<body>
  <div id="app">
    {{msg}}
    <hr>
    {{user.name}}
  </div>

  <script>

    var user = {
      name: "xiaoming",
      age: 20
    }
    //数据冻结，user就丢失了，响应式的关联
    Object.freeze(user);

    var vm = new Vue({
      //选项
      el: "#app",
      //数据驱动视图
      data: {
        msg: "helloworld",
        user
      },
      created(){
        console.log(this.msg)
      },



    })

    vm.$watch('msg', function (newval, oldval) {
      console.log(newval, oldval)
    })

  </script>

</body>

</html>